<template>
  <div class="bg">
    <div class="box">
      <div class="nav"></div>
      <div class="header">
        <div class="title">您的手机号已经注册过档案,请输入当时注册的姓名</div>
        <!-- <div class="title">{{ msg }}</div> -->
        <div class="line"></div>
        <div class="list">
          <div class="leftTitle">姓名</div>
          <div class="right">
            <input
              type="text"
              class="right-input"
              v-model="name"
              placeholder="请输入你的姓名"
            />
          </div>
        </div>
        <div class="line2"></div>
        <div class="btn" @click="goNext()">下一步</div>
        <div class="lookHelp" @click="help">查看帮助</div>
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
import { Dialog } from "vant";
import { getUserByPhoneAndRealNameApi } from "@/service/api.js";
import { bindWxopenidApi } from "@/service/api.js";
export default {
  name: "index",
  data() {
    return {
      token: "",
      phone: "",
      name: "",
      msg: "",
      userInfo: {},
      id: "",
      openid: "",
      username:"",
      mobile:"",
      card:"",
      unid:""
    };
  },
  components: {},
  created() {
    (this.phone = this.$route.query.phone),
      (this.openid = this.$route.query.openid);
    this.msg = this.$route.query.msg;

    console.log(this.phone);
    console.log(this.msg);
  },
  methods: {
    // 下一步
    goNext() {
          
      getUserByPhoneAndRealNameApi({
        mobile: this.phone,
        name: this.name,
      }).then((res) => {
        console.log(res);
        console.log(22);
        if (res.code == 4000) {
          console.log(res)
          this.username=res.data.name
          this.mobile=res.data.mobile
          this.card=res.data.cardno
           this.id = res.data.id;
        this.$router.push({
        name: 'shore',
        query: {
          username:this.username ,
          mobile:this.mobile,
          card:this.card ,
          id:this.id,
          openid:this.openid
        }
      })
          //成功执行跳转
        //   this.id = res.data.id;
        //   bindWxopenidApi({
        //     id: this.id,
        //     wxOpenid: this.openid,
        //     unid: "123sdsdsdsds545454",
        //     source: 16,
        //   }).then((res) => {
        //     console.log(res);
        //     if (res.code == 4000) {
        //       // 成功
        //       this.token = res.data;
        //       // 存入token
        //       let token = JSON.stringify(this.token);
        //       localStorage.setItem("token", token);

        //       this.$router.push({
        //         name: "shore",
        //       });
        //     }
        //   });

        //   console.log(res.msg);
        //   // 匹配档案
        // } else if (res.code == 4001) {
        //   this.msg = res.msg;
        //   Toast({
        //     message: this.msg,
        //   });
        //   console.log(111);
        }else if(res.code==4001){
          this.msg = res.msg;
          Toast({
            message: this.msg,
          });
        }
      });
    },
    help() {
      // 帮助
      this.$router.push({
        name: "help",
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.bg {
  .box {
    .nav {
      height: 44px;
    }
    .header {
      .title {
        margin: 10px;
        width: 100%;
        font-size: 15px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #000000;
      }
      .line {
        width: 100%;
        height: 1px;
        background: #cccccc;
      }
      .list {
        width: 100%;
        height: 50px;
        // background: pink;
        display: flex;
        align-items: center;
        margin-left: 10px;
        margin-right: 10px;
        .leftTitle {
          margin-right: 40px;
          font-size: 20px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #000000;
        }
        .right {
          font-size: 10px;
          .right-input {
            width: 250px;
            height: 30px;
            border: 1px solid #cccccc;
            font-size: 15px;
          }
        }
      }
      .line2 {
        width: 100%;
        height: 1px;
        background: #cccccc;
        margin-bottom: 40px;
      }
      .btn {
        width: 300px;
        height: 40px;
        margin: 0 auto;
        background: #07c6b4;
        text-align: center;
        line-height: 40px;
        color: #ffffff;
        font-size: 15px;
      }
      .lookHelp {
        position: fixed;
        bottom: 20px;
        width: 100%;
        color: #07c6b4;
        font-size: 15px;
        text-align: center;
      }
    }
  }
}
</style>